<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
define("PRIMARY_KEY","act_nr_id");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_actnrlist.php";
$FileTemplate  = "ais_transaction_actnrlist_jobcosting_list.html";

$PageSize      = 10 ;
$TableName     = "tbljoborder_costing";
$HTMLGridList  = "ActivityNRGrid";

//************ FORM ACTION **************
    if (GetParam("Action","")=="Delete") {
        DeleteRecord ("txtCheck",$PageSize);
    }

$PreserveGet = GetQueryString("All", array("PageNum"));
//Initiate Database Table For Search;
$FNama = GetParam("nameSearch","");
$FCode = GetParam("codeSearch","");

$temp_no_urut = GetParam("no_urut","");
$jo_id = GetParam("jo_id","");

if(!empty($temp_no_urut))
{
  $no_urut = GetParam("no_urut","");

}
else
{
   $no_urut = "";
}

$FormName = GetParam("FormName","");


//******* DATABASE FORM QUERY ***********

$SQL = "SELECT * FROM ".$TableName." a
        JOIN tblactivity_setup b ON a.activities_id = b.act_nr_id
        ";

if ($FNama)
    if (strlen($WHERE)) $WHERE .= " AND "." b.actname like '%".$FNama."%'";
    else $WHERE .= " b.actname like '%".$FNama."%'";
if ($FCode)
    if (strlen($WHERE)) $WHERE .= " AND "." b.actcode like '%".$FCode."%'";
    else $WHERE .= " b.actcode like '%".$FCode."%'";

    if (strlen($WHERE)) $WHERE = " WHERE a.jo_id = '".$jo_id."' AND a.jo_costing_appv_status = 'approved_2' AND ".$WHERE;
    else $WHERE = " WHERE a.jo_id = '".$jo_id."' AND a.jo_costing_appv_status = 'approved_2' ";


$SQL = $SQL.$WHERE;


//Count

$WHERE = "";

$SQLCount = "SELECT count(*) FROM ".$TableName." a
        JOIN tblactivity_setup b ON a.activities_id = b.act_nr_id
        ";

if ($FNama)
    if (strlen($WHERE)) $WHERE .= " AND "." b.actname like '%".$FNama."%'";
    else $WHERE .= " b.actname like '%".$FNama."%'";
if ($FCode)
    if (strlen($WHERE)) $WHERE .= " AND "." b.actcode like '%".$FCode."%'";
    else $WHERE .= " b.actcode like '%".$FCode."%'";

    if (strlen($WHERE)) $WHERE = " WHERE a.jo_id = '".$jo_id."' AND a.jo_costing_appv_status = 'approved_2' AND ".$WHERE;
    else $WHERE = " WHERE a.jo_id = '".$jo_id."' AND a.jo_costing_appv_status = 'approved_2' ";


$SQLCount = $SQLCount.$WHERE;



//******* SHOW FORM CONTENT *********

//$PageNum = 1;
//$RecCnt = $DBConnection->dbc->get_var($SQLCount) ;
//if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");
//Default value
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
  $PageNum = $_GET['PageNum'] ;
} else {
    $PageNum = 1 ;
}

//Default value
if (isset($_GET['RecCnt'])) {
  $RecCnt = intval($_GET['RecCnt']) ;
} else {
    $RecCnt = -1 ;
}


$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$RecCnt = $TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);
$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ;
$TBS->Show();



?>
